home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performNurbsCube.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  18.6 KB  |  732 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  6 May 1997
  22. //  Author:         mm
  23. //
  24. //  Description:
  25. //    This script defines the option box for the NURBS cube menu item.
  26. //
  27.  
  28. //
  29. //  Procedure Name:
  30. //      setOptionVars
  31. //
  32. //  Description:
  33. //        Initialize the option values.
  34. //
  35. //  Input Arguments:
  36. //        Whether to set the options to default values.
  37. //
  38. //  Return Value:
  39. //      None.
  40. //
  41. proc setOptionVars(int $forceFactorySettings)
  42. {
  43.     if ($forceFactorySettings ||  !`optionVar -exists nurbsCubePivotType`) {
  44.         optionVar -intValue nurbsCubePivotType 1;
  45.     }
  46.  
  47.     if ($forceFactorySettings ||  !`optionVar -exists nurbsCubePivotX`) {
  48.         optionVar -floatValue nurbsCubePivotX 0.0;
  49.     }
  50.     if ($forceFactorySettings ||  !`optionVar -exists nurbsCubePivotY`) {
  51.         optionVar -floatValue nurbsCubePivotY 0.0;
  52.     }
  53.     if ($forceFactorySettings ||  !`optionVar -exists nurbsCubePivotZ`) {
  54.         optionVar -floatValue nurbsCubePivotZ 0.0;
  55.     }
  56.  
  57.  
  58.     string $isitYup = `upAxis -q -ax`;
  59.     if( "y" == $isitYup ) {
  60.         if ($forceFactorySettings ||  !`optionVar -exists nurbsCubeAxisType`) {
  61.             optionVar -intValue nurbsCubeAxisType 2;
  62.         }
  63.  
  64.         if ($forceFactorySettings ||  !`optionVar -exists nurbsCubeAxisX`) {
  65.             optionVar -floatValue nurbsCubeAxisX 0.0;
  66.         }
  67.         if ($forceFactorySettings ||  !`optionVar -exists nurbsCubeAxisY`) {
  68.             optionVar -floatValue nurbsCubeAxisY 1.0;
  69.         }
  70.         if ($forceFactorySettings ||  !`optionVar -exists nurbsCubeAxisZ`) {
  71.             optionVar -floatValue nurbsCubeAxisZ 0.0;
  72.         }
  73.     }
  74.     else {
  75.         if ($forceFactorySettings ||  !`optionVar -exists nurbsCubeAxisType`) {
  76.             optionVar -intValue nurbsCubeAxisType 3;
  77.         }
  78.  
  79.         if ($forceFactorySettings ||  !`optionVar -exists nurbsCubeAxisX`) {
  80.             optionVar -floatValue nurbsCubeAxisX 0.0;
  81.         }
  82.         if ($forceFactorySettings ||  !`optionVar -exists nurbsCubeAxisY`) {
  83.             optionVar -floatValue nurbsCubeAxisY 0.0;
  84.         }
  85.         if ($forceFactorySettings ||  !`optionVar -exists nurbsCubeAxisZ`) {
  86.             optionVar -floatValue nurbsCubeAxisZ 1.0;
  87.         }
  88.     }
  89.  
  90.  
  91.     if ($forceFactorySettings ||  !`optionVar -exists nurbsCubeWidth`) {
  92.         optionVar -floatValue nurbsCubeWidth 1.0;
  93.     }
  94.     if ($forceFactorySettings ||  !`optionVar -exists nurbsCubeLengthRatio`) {
  95.         optionVar -floatValue nurbsCubeLengthRatio 1.0;
  96.     }
  97.     if ($forceFactorySettings ||  !`optionVar -exists nurbsCubeHeightRatio`) {
  98.         optionVar -floatValue nurbsCubeHeightRatio 1.0;
  99.     }
  100.  
  101.  
  102.  
  103.     if ($forceFactorySettings ||  !`optionVar -exists nurbsCubeDegree`) {
  104.         optionVar -intValue nurbsCubeDegree 3;
  105.     }
  106.  
  107.  
  108.  
  109.     if ($forceFactorySettings ||  !`optionVar -exists nurbsCubePatchesU`) {
  110.         optionVar -intValue nurbsCubePatchesU 1;
  111.     }
  112.     if ($forceFactorySettings ||  !`optionVar -exists nurbsCubePatchesV`) {
  113.         optionVar -intValue nurbsCubePatchesV 1;
  114.     }
  115. }
  116.  
  117. //
  118. //  Procedure Name:
  119. //      nurbsCubeSetup
  120. //
  121. //  Description:
  122. //        Update the state of the option box UI to reflect the option values.
  123. //
  124. //  Input Arguments:
  125. //      parent               - Top level parent layout of the option box UI.
  126. //                             Required so that UI object names can be 
  127. //                             successfully resolved.
  128. //
  129. //    forceFactorySettings - Whether the option values should be set to
  130. //                             default values.
  131. //
  132. //  Return Value:
  133. //      None.
  134. //
  135. global proc nurbsCubeSetup(string $parent, int $forceFactorySettings)
  136. {
  137.     //    Retrieve the option settings
  138.     //
  139.     setOptionVars($forceFactorySettings);
  140.  
  141.     setParent $parent;
  142.  
  143.     //    Query the optionVar's and set the values into the controls.
  144.  
  145.     // Pivot
  146.     //
  147.     int $pivotType = `optionVar -q nurbsCubePivotType`;
  148.     float $pivotX = `optionVar -q nurbsCubePivotX`;
  149.     float $pivotY = `optionVar -q nurbsCubePivotY`;
  150.     float $pivotZ = `optionVar -q nurbsCubePivotZ`;
  151.     if ($pivotType == 1) {
  152.         $pivotX = 0;
  153.         $pivotY = 0;
  154.         $pivotZ = 0;
  155.     }
  156.     radioButtonGrp -e -select $pivotType nurbsCubePivotType;
  157.     floatFieldGrp -e
  158.         -v1 $pivotX -v2 $pivotY -v3 $pivotZ
  159.         nurbsCubePivot;
  160.  
  161.     // Axis
  162.     //
  163.     int $axisType = `optionVar -q nurbsCubeAxisType`;
  164.     float $axis[3];
  165.     switch($axisType) {
  166.       case 1:
  167.         $axis[0] = 1;
  168.         $axis[1] = 0;
  169.         $axis[2] = 0;
  170.         break;
  171.       case 2:
  172.         $axis[0] = 0;
  173.         $axis[1] = 1;
  174.         $axis[2] = 0;
  175.         break;
  176.       case 3:
  177.         $axis[0] = 0;
  178.         $axis[1] = 0;
  179.         $axis[2] = 1;
  180.         break;
  181.       case 4:
  182.         $axis[0] = `optionVar -q nurbsCubeAxisX`;
  183.         $axis[1] = `optionVar -q nurbsCubeAxisY`;
  184.         $axis[2] = `optionVar -q nurbsCubeAxisZ`;
  185.         break;
  186.       case 5:
  187.         $axis = `nurbsViewDirectionVector 1`;
  188.         break;
  189.     }
  190.  
  191.     if( $axisType < 4 ) {
  192.         radioButtonGrp -e -select $axisType nurbsCubeAxisType1;
  193.     }
  194.     else {
  195.         radioButtonGrp -e -select ($axisType - 3) nurbsCubeAxisType2;
  196.     }
  197.     floatFieldGrp -e
  198.         -v1 $axis[0] -v2 $axis[1] -v3 $axis[2]
  199.         nurbsCubeAxis;
  200.  
  201.     // Width
  202.     //
  203.     float $cubeWidth = `optionVar -q nurbsCubeWidth`;
  204.     floatSliderGrp -e 
  205.         -v $cubeWidth
  206.         nurbsCubeWidth;
  207.  
  208.     // Length Ratio
  209.     //
  210.     float $ratio = `optionVar -q nurbsCubeLengthRatio`;
  211.     floatSliderGrp -e 
  212.         -v `nurbsRatioConvert $cubeWidth $ratio false` 
  213.         nurbsCubeLength;
  214.  
  215.     // Height Ratio
  216.     //
  217.     $ratio = `optionVar -q nurbsCubeHeightRatio`;
  218.     floatSliderGrp -e 
  219.         -v `nurbsRatioConvert $cubeWidth $ratio false` 
  220.         nurbsCubeHeight;
  221.  
  222.     // Degree
  223.     //
  224.     int $degree = `optionVar -q nurbsCubeDegree`;
  225.     int $degreeBtn;
  226.     switch($degree) {
  227.         case 1: radioButtonGrp -e -select 1 nurbsCubeDegree123; break;
  228.         case 2: radioButtonGrp -e -select 2 nurbsCubeDegree123; break;
  229.         case 3: radioButtonGrp -e -select 3 nurbsCubeDegree123; break;
  230.         case 5: radioButtonGrp -e -select 1 nurbsCubeDegree57; break;
  231.         case 7: radioButtonGrp -e -select 2 nurbsCubeDegree57; break;
  232.         default: radioButtonGrp -e -select 3 nurbsCubeDegree123; break;
  233.     }
  234.  
  235.     // Patches U
  236.     //
  237.     intSliderGrp -e
  238.         -v `optionVar -q nurbsCubePatchesU`
  239.         nurbsCubePatchesU;
  240.  
  241.     // Patches V
  242.     //
  243.     intSliderGrp -e
  244.         -v `optionVar -q nurbsCubePatchesV`
  245.         nurbsCubePatchesV;
  246.  
  247.     // Disable or enable some controls depending on other values.
  248.     //
  249.     if ($pivotType == 2)
  250.         floatFieldGrp -e -enable 1 nurbsCubePivot;
  251.     else
  252.         floatFieldGrp -e -enable 0 nurbsCubePivot;
  253.  
  254.     if ($axisType == 4)
  255.         floatFieldGrp -e -enable 1 nurbsCubeAxis;
  256.     else
  257.         floatFieldGrp -e -enable 0 nurbsCubeAxis;
  258. }
  259.  
  260. //
  261. //  Procedure Name:
  262. //      nurbsCubeCallback
  263. //
  264. //  Description:
  265. //        Update the option values with the current state of the option box UI.
  266. //
  267. //  Input Arguments:
  268. //      parent - Top level parent layout of the option box UI.  Required so
  269. //               that UI object names can be successfully resolved.
  270. //
  271. //    doIt   - Whether the command should execute.
  272. //
  273. //  Return Value:
  274. //      None.
  275. //
  276. global proc nurbsCubeCallback(string $parent, int $doIt)
  277. {
  278.     setParent $parent;
  279.  
  280.     //    Set the optionVar's from the control values, and then
  281.     //    perform the command.
  282.  
  283.     // Pivot
  284.     //
  285.     int $pivotType = `radioButtonGrp -q -select nurbsCubePivotType`;
  286.     optionVar -intValue nurbsCubePivotType $pivotType;
  287.     if ($pivotType == 2) {
  288.         optionVar -floatValue nurbsCubePivotX `floatFieldGrp -q -v1 nurbsCubePivot`;
  289.         optionVar -floatValue nurbsCubePivotY `floatFieldGrp -q -v2 nurbsCubePivot`;
  290.         optionVar -floatValue nurbsCubePivotZ `floatFieldGrp -q -v3 nurbsCubePivot`;
  291.     }
  292.  
  293.     // Axis
  294.     //
  295.     int $axisType = `radioButtonGrp -q -select nurbsCubeAxisType1`;
  296.     if( 0 == $axisType ) {
  297.         $axisType = `radioButtonGrp -q -select nurbsCubeAxisType2` + 3;
  298.     }
  299.     optionVar -intValue nurbsCubeAxisType $axisType;
  300.     if( ($axisType == 4) || ($axisType == 5) ) {
  301.         optionVar -floatValue nurbsCubeAxisX `floatFieldGrp -q -v1 nurbsCubeAxis`;
  302.         optionVar -floatValue nurbsCubeAxisY `floatFieldGrp -q -v2 nurbsCubeAxis`;
  303.         optionVar -floatValue nurbsCubeAxisZ `floatFieldGrp -q -v3 nurbsCubeAxis`;
  304.     }
  305.  
  306.     // Width
  307.     //
  308.     float $cubeWidth = `floatSliderGrp -q -v nurbsCubeWidth`;
  309.     optionVar -floatValue nurbsCubeWidth $cubeWidth;
  310.  
  311.     // Length Ratio
  312.     //
  313.     float $ratio = nurbsRatioConvert($cubeWidth, `floatSliderGrp -q -v nurbsCubeLength`, true);
  314.     optionVar -floatValue nurbsCubeLengthRatio $ratio;
  315.  
  316.     // Height Ratio
  317.     //
  318.     $ratio = nurbsRatioConvert($cubeWidth, `floatSliderGrp -q -v nurbsCubeHeight`, true);
  319.     optionVar -floatValue nurbsCubeHeightRatio $ratio;
  320.  
  321.     // Degree
  322.     //
  323.     int $degreeBtn123 = `radioButtonGrp -q -select nurbsCubeDegree123`;
  324.     int $degreeBtn57 = `radioButtonGrp -q -select nurbsCubeDegree57`;
  325.     int $degree;
  326.     switch($degreeBtn123) {
  327.         case 1: $degree = 1; break;
  328.         case 2: $degree = 2; break;
  329.         case 3: $degree = 3; break;
  330.         default:
  331.             switch($degreeBtn57) {
  332.                 case 1: $degree = 5; break;
  333.                 case 2: $degree = 7; break;
  334.                 default: $degree = 3; break;
  335.             }
  336.             break;
  337.     }
  338.     optionVar -intValue nurbsCubeDegree
  339.         $degree;
  340.  
  341.     // Patches U
  342.     //
  343.     optionVar -intValue nurbsCubePatchesU
  344.         `intSliderGrp -q -v nurbsCubePatchesU`;
  345.  
  346.     // Patches V
  347.     //
  348.     optionVar -intValue nurbsCubePatchesV
  349.         `intSliderGrp -q -v nurbsCubePatchesV`;
  350.  
  351.     if ($doIt) {
  352.         performNurbsCube 0; 
  353.         addToRecentCommandQueue "performNurbsCube 0" "NURBS Cube";
  354.     }
  355. }
  356.  
  357. //
  358. //  Procedure Name:
  359. //      nurbsCubeOptions
  360. //
  361. //  Description:
  362. //        Construct the option box UI.  Involves accessing the standard option
  363. //        box and customizing the UI accordingly.
  364. //
  365. //  Input Arguments:
  366. //      None.
  367. //
  368. //  Return Value:
  369. //      None.
  370. //
  371. proc nurbsCubeOptions()
  372. {
  373.     //    Name of the command for this option box.
  374.     //
  375.     string $commandName = "nurbsCube";
  376.  
  377.     //    Build the option box actions.
  378.     //
  379.     string $callback = ($commandName + "Callback");
  380.     string $setup = ($commandName + "Setup");
  381.  
  382.     //    STEP 1:  Get the option box.
  383.     //    ============================
  384.     //
  385.     //    The value returned is the name of the layout to be used as
  386.     //    the parent for the option box UI.
  387.     //
  388.     string $layout = getOptionBox();
  389.     setParent $layout;
  390.     
  391.     //    STEP 2:  Pass the command name to the option box.
  392.     //    =================================================
  393.     //
  394.     //    Any default option box behaviour based on the command name is set 
  395.     //    up with this call.  For example, updating the 'Help' menu item with
  396.     //    the name of the command.
  397.     //
  398.     setOptionBoxCommandName($commandName);
  399.     
  400.     //    STEP 3:  Activate the default UI template.
  401.     //    ==========================================
  402.     //
  403.     //    Activate the default UI template so that the layout of this 
  404.     //    option box is consistent with the layout of the rest of the 
  405.     //    application.
  406.     //
  407.     setUITemplate -pushTemplate DefaultTemplate;
  408.  
  409.     //    Turn on the wait cursor.
  410.     //
  411.     waitCursor -state 1;
  412.  
  413.     //    STEP 4: Create option box contents.
  414.     //    ===================================
  415.     //
  416.     tabLayout -scr true -tv false;
  417.     string $parent = `columnLayout -adjustableColumn 1`;
  418.  
  419.     radioButtonGrp -label "Pivot"
  420.         -numberOfRadioButtons 2
  421.         -l1 "Object"
  422.         -l2 "User Defined"
  423.         -select 1
  424.         nurbsCubePivotType;
  425.  
  426.     floatFieldGrp -label "Pivot Point"
  427.         -numberOfFields 3
  428.         nurbsCubePivot;
  429.  
  430.     radioButtonGrp -label "Axis"
  431.         -numberOfRadioButtons 3
  432.         -l1 "X"
  433.         -l2 "Y"
  434.         -l3 "Z"
  435.         -select 1
  436.         nurbsCubeAxisType1;
  437.  
  438.     radioButtonGrp
  439.         -numberOfRadioButtons 2
  440.         -l1 "Free"
  441.         -l2 "Active View"
  442.         -scl nurbsCubeAxisType1
  443.         nurbsCubeAxisType2;
  444.  
  445.     floatFieldGrp -label "Axis Definition"
  446.         -numberOfFields 3
  447.         nurbsCubeAxis;
  448.  
  449.     separator;
  450.  
  451.     floatSliderGrp -label "Width"
  452.         -fmn 0.0001 -min 0.0001
  453.         -fmx 1000 -max 100
  454.         nurbsCubeWidth;
  455.  
  456.     floatSliderGrp -label "Length"
  457.         -fmn 0 -min 0
  458.         -fmx 1000 -max 100
  459.         nurbsCubeLength;
  460.  
  461.     floatSliderGrp -label "Height"
  462.         -fmn 0 -min 0
  463.         -fmx 1000 -max 100
  464.         nurbsCubeHeight;
  465.  
  466.     radioButtonGrp -label "Surface Degree"
  467.         -numberOfRadioButtons 3
  468.         -l1 "1 Linear"
  469.         -l2 "2" // Quadratic
  470.         -l3 "3 Cubic"
  471.         -select 3
  472.         nurbsCubeDegree123;
  473.  
  474.     radioButtonGrp -shareCollection nurbsCubeDegree123
  475.         -numberOfRadioButtons 2
  476.         -l1 "5" // Quintic
  477.         -l2 "7"
  478.         nurbsCubeDegree57;
  479.  
  480.     intSliderGrp -l "U Patches"
  481.         -field true
  482.         -min 1
  483.         nurbsCubePatchesU;
  484.  
  485.     intSliderGrp -l "V Patches"
  486.         -field true
  487.         -min 1
  488.         nurbsCubePatchesV;
  489.  
  490.     // Set the pivot float fields to only be enabled when "Pivot" is "User Defined"
  491.     //
  492.     string $pivotEnable = ("floatFieldGrp -e -en 1 nurbsCubePivot;"
  493.         + "floatFieldGrp -e"
  494.         + " -v1 `optionVar -q nurbsCubePivotX`"
  495.         + " -v2 `optionVar -q nurbsCubePivotY`"
  496.         + " -v3 `optionVar -q nurbsCubePivotZ`"
  497.         + " nurbsCubePivot;"
  498.         );
  499.     string $pivotDisable = "floatFieldGrp -e -en 0 nurbsCubePivot;";
  500.     radioButtonGrp -edit
  501.         -cc1 ($pivotDisable + "floatFieldGrp -e -value 0.0 0.0 0.0 0.0 nurbsCubePivot;")
  502.         -cc2 $pivotEnable
  503.         nurbsCubePivotType;
  504.  
  505.     // Set the axis float fields to only be enabled when "Axis Preset" is "Free"
  506.     //
  507.     string $axisEnable = ("floatFieldGrp -e -en 1 nurbsCubeAxis;"
  508.         + "floatFieldGrp -e"
  509.         + " -v1 `optionVar -q nurbsCubeAxisX`"
  510.         + " -v2 `optionVar -q nurbsCubeAxisY`"
  511.         + " -v3 `optionVar -q nurbsCubeAxisZ`"
  512.         + " nurbsCubeAxis;"
  513.         );
  514.     string $axisDisable = "floatFieldGrp -e -en 0 nurbsCubeAxis;";
  515.     radioButtonGrp -edit
  516.         -cc1 ($axisDisable + "floatFieldGrp -e -value 1.0 0.0 0.0 0.0 nurbsCubeAxis;")
  517.         -cc2 ($axisDisable + "floatFieldGrp -e -value 0.0 1.0 0.0 0.0 nurbsCubeAxis;")
  518.         -cc3 ($axisDisable + "floatFieldGrp -e -value 0.0 0.0 1.0 0.0 nurbsCubeAxis;")
  519.         nurbsCubeAxisType1;
  520.     radioButtonGrp -edit
  521.         -cc1 $axisEnable
  522.         -cc2 $axisDisable
  523.         nurbsCubeAxisType2;
  524.  
  525.     //    Turn off the wait cursor.
  526.     //
  527.     waitCursor -state 0;
  528.     
  529.     //    Step 5: Deactivate the default UI template.
  530.     //      ===========================================
  531.     //
  532.     setUITemplate -popTemplate;
  533.  
  534.     //    Step 6: Customize the buttons.  
  535.     //    ==============================
  536.     //
  537.     //    Provide more descriptive labels for the buttons.
  538.     //    Disable those buttons that are not applicable to the option box.
  539.     //    Attach actions to those buttons that are applicable to the option box.
  540.  
  541.     //    'Apply' button.
  542.     //
  543.     string $applyBtn = getOptionBoxApplyBtn();
  544.     button -edit
  545.         -label "Create"
  546.         -command ($callback + " " + $parent + " " + 1)
  547.         $applyBtn;
  548.  
  549.     //    'Save' button.
  550.     //
  551.     string $saveBtn = getOptionBoxSaveBtn();
  552.     button -edit 
  553.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  554.         $saveBtn;
  555.  
  556.     //    'Reset' button.
  557.     //
  558.     string $resetBtn = getOptionBoxResetBtn();
  559.     button -edit 
  560.         -command ($setup + " " + $parent + " " + 1)
  561.         $resetBtn;
  562.  
  563.     //    Step 7: Set the option box title.
  564.     //    =================================
  565.     //
  566.     setOptionBoxTitle("NURBS Cube Options");
  567.  
  568.     //    Step 8: Customize the 'Help' menu item text.
  569.     //    ============================================
  570.     //
  571.     setOptionBoxHelpTag( "NurbsCube" );
  572.  
  573.     //    Set the current values of the option box.
  574.     //    =========================================
  575.     //
  576.     eval (($setup + " " + $parent + " " + 0));    
  577.     
  578.     //    Show the option box.
  579.     //    ====================
  580.     //
  581.     showOptionBox();
  582. }
  583.  
  584. //
  585. //  Procedure Name:
  586. //      nurbsCubeHelp
  587. //
  588. //  Description:
  589. //        Return a short description about this command.
  590. //
  591. //  Input Arguments:
  592. //      None.
  593. //
  594. //  Return Value:
  595. //      string.
  596. //
  597. proc string nurbsCubeHelp()
  598. {
  599.     return 
  600.     "  Command: nurbsCube - create a NURBS cube.\n";
  601. }
  602.  
  603. //
  604. //  Procedure Name:
  605. //      assembleCmd
  606. //
  607. //  Description:
  608. //        Construct the command that will apply the option box values.
  609. //
  610. //  Input Arguments:
  611. //      None.
  612. //
  613. proc string assembleCmd()
  614. {
  615.     string $cmd = "nurbsCube";
  616.  
  617.     setOptionVars(false);
  618.  
  619.     int $pivotType = `optionVar -q nurbsCubePivotType`;
  620.     float $pivotX = `optionVar -q nurbsCubePivotX`;
  621.     float $pivotY = `optionVar -q nurbsCubePivotY`;
  622.     float $pivotZ = `optionVar -q nurbsCubePivotZ`;
  623.     if ($pivotType == 1) {
  624.         $pivotX = 0;
  625.         $pivotY = 0;
  626.         $pivotZ = 0;
  627.     }
  628.  
  629.     // Axis
  630.     //
  631.     int $axisType = `optionVar -q nurbsCubeAxisType`;
  632.     float $axis[3];
  633.     switch($axisType) {
  634.       case 1:
  635.         $axis[0] = 1;
  636.         $axis[1] = 0;
  637.         $axis[2] = 0;
  638.         break;
  639.       case 2:
  640.         $axis[0] = 0;
  641.         $axis[1] = 1;
  642.         $axis[2] = 0;
  643.         break;
  644.       case 3:
  645.         $axis[0] = 0;
  646.         $axis[1] = 0;
  647.         $axis[2] = 1;
  648.         break;
  649.       case 4:
  650.         $axis[0] = `optionVar -q nurbsCubeAxisX`;
  651.         $axis[1] = `optionVar -q nurbsCubeAxisY`;
  652.         $axis[2] = `optionVar -q nurbsCubeAxisZ`;
  653.         break;
  654.       case 5:
  655.         $axis = `nurbsViewDirectionVector 1`;
  656.         break;
  657.     }
  658.  
  659.     // History
  660.     //
  661.     int $doHistory = `constructionHistory -q -toggle`;
  662.  
  663.     $cmd = ($cmd
  664.         + " -p " + $pivotX + " " + $pivotY + " " + $pivotZ
  665.         + " -ax " + $axis[0] + " " + $axis[1] + " " + $axis[2]
  666.         + " -w " + `optionVar -query nurbsCubeWidth`
  667.         + " -lr " + `optionVar -query nurbsCubeLengthRatio`
  668.         + " -hr " + `optionVar -query nurbsCubeHeightRatio`
  669.         + " -d " + `optionVar -query nurbsCubeDegree`
  670.         + " -u " + `optionVar -query nurbsCubePatchesU`
  671.         + " -v " + `optionVar -query nurbsCubePatchesV`
  672.         + " -ch " + $doHistory
  673.         + "; objectMoveCommand");
  674.  
  675.     return $cmd;
  676. }
  677.  
  678. //
  679. //  Procedure Name:
  680. //      performNurbsCube
  681. //
  682. //  Description:
  683. //        Perform the nurbsCube command using the corresponding 
  684. //        option values.  This procedure will also show the option box
  685. //        window if necessary as well as construct the command string
  686. //        that will invoke the nurbsCube command with the current
  687. //        option box values.
  688. //
  689. //  Input Arguments:
  690. //      0 - Execute the command.
  691. //      1 - Show the option box dialog.
  692. //      2 - Return the command.
  693. //
  694. //  Return Value:
  695. //      None.
  696. //
  697. global proc string performNurbsCube(int $action)
  698. {
  699.     string $cmd = "";
  700.  
  701.     switch ($action) {
  702.  
  703.         //    Execute the command.
  704.         //
  705.         case 0:
  706.             //    Get the command.
  707.             //
  708.             $cmd = `assembleCmd`;
  709.  
  710.             //    Execute the command with the option settings.
  711.             //
  712.             evalEcho($cmd);
  713.  
  714.             break;
  715.  
  716.         //    Show the option box.
  717.         //
  718.         case 1:
  719.             nurbsCubeOptions;
  720.             break;
  721.  
  722.         //    Return the command string.
  723.         //
  724.         case 2:
  725.             //    Get the command.
  726.             //
  727.             $cmd = `assembleCmd`;
  728.             break;
  729.     }
  730.     return $cmd;
  731. }
  732.